home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet internetowy / Czytniki RSS / RSS Bandit 1.3.0.42 / RssBandit Installer.msi / _172FF5180BC61D3C6D240F14338A23AA / _CB810C65E749481E957EB241CE2B6BB0 < prev    next >
Text File  |  2005-03-12  |  3KB  |  88 lines

  1. using System; 
  2. using System.Xml;
  3. using System.IO; 
  4. using System.Xml.XPath; 
  5. using System.Xml.Xsl;
  6. using Syndication.Extensibility;
  7. using System.Windows.Forms;
  8. using System.Diagnostics;
  9. using Microsoft.Win32;
  10.  
  11. namespace BlogExtension.BlogThis.WBloggar {
  12.  
  13.  
  14.        public class BlogThisUsingWbloggarPlugin:IBlogExtension {
  15.     
  16.      public static string styleSheet = @"<xsl:stylesheet version='1.0' 
  17.   xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
  18.  
  19.   <xsl:output method='html' /> 
  20.   <xsl:variable name='feed-title' select='/rss/channel/title' />
  21.  
  22.   <xsl:template match='/'>
  23.     <xsl:apply-templates select='//item' />
  24.   </xsl:template>
  25.  
  26.   <xsl:template match='/rss/channel/item'>
  27.     <title>RE: <xsl:value-of select='title' /></title>
  28.     <xsl:choose>
  29.       <xsl:when test='description'>
  30.     <blockquote>
  31.       <xsl:value-of disable-output-escaping='yes' select='description' />
  32.     </blockquote>
  33.       </xsl:when>
  34.       <xsl:otherwise  xmlns:xhtml='http://www.w3.org/1999/xhtml'>
  35.     <blockquote>
  36.       <xsl:copy-of select='xhtml:body' />
  37.       </blockquote>
  38.     </xsl:otherwise> 
  39.     </xsl:choose> 
  40.     <i>[Via <xsl:choose><xsl:when test='link'><a href='{link}'><xsl:value-of select='$feed-title' /></a></xsl:when>
  41.     <xsl:otherwise><xsl:value-of select='$feed-title' /></xsl:otherwise> 
  42.     </xsl:choose>]</i>         
  43.   </xsl:template> 
  44. </xsl:stylesheet>"; 
  45.  
  46.          public bool HasConfiguration { get {return false; } }
  47.      public bool HasEditingGUI{ get {return true; } }
  48.  
  49.  
  50.      public void Configure(IWin32Window parent){
  51.        /* yeah, right */
  52.      }
  53.  
  54.  
  55.      public string DisplayName { get { return Resource.Manager["RES_MenuWBloggarCaption"]; } }
  56.  
  57.  
  58.      public void BlogItem(System.Xml.XPath.IXPathNavigable rssFragment, bool edited) {
  59.  
  60.        /* check to see if w::bloggar installed */ 
  61.        RegistryKey rkey;
  62.        rkey = Registry.CurrentUser.OpenSubKey(@"Software\VB and VBA Program Settings\Bloggar");
  63.  
  64.        if(rkey == null){
  65.          throw new ApplicationException(Resource.Manager["RES_ExceptionWBloggarNotFound"]); 
  66.        }
  67.        
  68.        string wbloggarPath = ((string) rkey.GetValue("InstallPath")); 
  69.        
  70.        XslTransform transform = new XslTransform();
  71.        transform.Load(new XmlTextReader(new StringReader(styleSheet))); 
  72.  
  73.        string tempfile = Path.GetTempFileName(); 
  74.        transform.Transform(rssFragment, null, new StreamWriter(tempfile));        
  75.               
  76.        Process.Start(wbloggarPath + @"\wbloggar.exe", tempfile); 
  77.      }          
  78.      
  79.      
  80.      public static void Main(string[] args){
  81.        BlogThisUsingWbloggarPlugin plugin = new BlogThisUsingWbloggarPlugin(); 
  82.        plugin.BlogItem(new XPathDocument("rssitem2.xml"), false); 
  83.      }
  84.  
  85.        }
  86.  
  87. }
  88.